import { Body, Controller, Get, Post } from '@nestjs/common';
import { Public } from '@/decorators/public.decorator';
import { AuthService } from '@/modules/auth/auth.service';
import { wrapperResponse } from '@/utils';
import { SigninUserDto } from '@/modules/auth/signin-user.dto';

@Controller('auth')
export class AuthController {
  constructor(private authService: AuthService) {}

  @Public()
  @Post('login')
  login(@Body() body: SigninUserDto): Promise<any> {
    return wrapperResponse(
      this.authService.login(body.username, body.password),
      '登录成功',
    );
  }

  @Public()
  @Post('signup')
  signup(@Body() body: SigninUserDto) {
    return this.authService.signup(body.username, body.password);
  }
}
